import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
df=pd.read_csv("./持仓记录表.csv",encoding="utf-8", header=0)
dfss = pd.DataFrame(columns=['date','cash_all'])

#将持仓记录表转化为更加简洁的dfss表
for hang in range(df.shape[0]):
    dfss=dfss.append({'date':df.iloc[hang,0],'cash_all':''},ignore_index=True)
df=df.fillna("{'持仓价值':0}")
for roll in range(df.shape[0]):
    newcash=0
    for lie in range(1,df.shape[1]): 
        transfer=eval(df.iloc[roll,lie])
        newcash+=float(transfer['持仓价值'])
    dfss.iloc[roll,1]=newcash
dfss.set_index("date",inplace=True)
dfss.to_csv("./result.csv")